Skip to content

fix(cli): one-shot capture waits for stdout to drain before settling - #1027

Merged
edgar-durand merged 1 commit into
mainfrom
fix/spawn-capture-drain
Nov 23, 2026
Merged

edgar-durand merged 1 commit into
mainfrom
fix/spawn-capture-drain

Conversation

@edgar-durand

@edgar-durand edgar-durand commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The v2.76.48 release gate failed on antigravity.test.ts > returns null and surfaces stdout when agy exits non-zero, which got '' instead of API_KEY_INVALID. spawnAndCapture settled on the child's exit event, and exit can fire before the last stdout chunk has been read. The same race can cut the end off a successful one-shot answer (Preview detect, AI summary).

What

The capture now settles on close, which fires once stdio is drained. A 500 ms grace after exit still settles it if a grandchild keeps the pipe open.

Tests

Every test file that uses spawnAndCapture or generateOneShot passed twice in a row (96 tests). tsc --noEmit is clean.

🤖 Generated with Claude Code


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

spawnAndCapture settled on the child's `exit`, which can fire before the last
stdout chunk is read: the v2.76.48 release gate lost a failed one-shot's
output ("API_KEY_INVALID" -> ''), and a successful one-shot (preview detect,
AI summary) could lose the tail of its answer the same way. Settle on `close`
(stdio drained), with a 500 ms grace after `exit` for a grandchild that keeps
the pipe open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@edgar-durand
edgar-durand merged commit 930f063 into main Nov 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants